package com.ashin;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import org.junit.Test;

/**
 * Hello world!
 */
@EnableApolloConfig
public class App {

    /**
     * 读取默认application的配置
     */
    @Test
    public void testDefaultNamespace() {
        //config instance is singleton for each namespace and is never null
        Config config = ConfigService.getAppConfig();
        String someKey = "server.port";
        String someDefaultValue = "8888";

        String value = config.getProperty(someKey, someDefaultValue);
        System.out.println(value);
    }

    /**
     * 读取公共的namespace
     */
    @Test
    public void testPublicNamespace() {
        //config instance is singleton for each namespace and is never null
        String somePublicNamespace = "javaDevelopa.345";
        Config config = ConfigService.getConfig(somePublicNamespace);
        String someKey = "batch.size";
        String someDefaultValue = "someDefaultValueForTheKey";
        String value = config.getProperty(someKey, someDefaultValue);
        System.out.println(value);
    }
}
